<!DOCTYPE html>
<html lang="zh-CN">
  <head>
    <meta charset="utf-8" />
    <title>镂空面绘制</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
    <meta http-equiv="X-UA-Compatible" content="IE=Edge" />
    <style>
      body,
      html,
      #container {
        overflow: hidden;
        width: 100%;
        height: 100%;
        margin: 0;
        font-family: "微软雅黑";
      }
    </style>
    <script src="//api.map.baidu.com/api?type=webgl&v=1.0&ak=xc76V8ddYmWQvw1aQtt2cBUgbV3HmQIH"></script>
  </head>
  <body>
    <div id="container"></div>
  </body>
</html>
<script>
  var map = new BMap.Map("container", {
    enableDblclickZoom: false,
    displayOptions: {
      building: false,
    },
  });
  map.centerAndZoom(new BMap.Point(116.718, 40.142), 11);
  map.enableScrollWheelZoom(true);

  var bd = new BMap.Boundary();
  bd.get("顺义区", function (rs) {
    console.log(rs);
    var hole = new BMap.Polygon(rs.boundaries, {
      fillColor: "#0071df",
      fillOpacity: 0.3,
      strokeColor: "#0071df",
      fillColor: "#a1c8ff",
      type: "dashed",
    });
    map.addOverlay(hole);
  });
</script>
